/**   
 * @Title: FootballHemaiGetListCommunicater.java 
 * @Package com.esun.rabbit2.communicaters 
 * @Description: (通讯接口,业务标号10005) 
 * @author:  Kuroky Chengxt@500wan.com
 * @date: 2011-8-16 下午04:54:42
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.hemaicenter;

import java.util.ArrayList;
import java.util.HashMap;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: FucaiHemaiGetListCommunicater
 * @Description: (获取福彩3D合买方案列表)
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2011-8-16 下午04:54:42
 * 
 */
public class FucaiHemaiGetListCommunicater extends ServerCommunicater {

	private ArrayList<Fucai3DHemaiListItemInfo> listHemaiListItemInfo = new ArrayList<Fucai3DHemaiListItemInfo>();

	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetHemaiListSucceed(String lotId, int sortCode, int sorterCode, int pageSize, int pageNo, String expect) {

		String strSorter = null;
		if (sorterCode == 1) {
			strSorter = Key.KEY_ASC;
		} else {
			strSorter = Key.KEY_DESC;
		}
		String strSort = null;
		if (sortCode == 0) {
			strSort = Key.KEY_RENQI;
		} else if (sortCode == 1) {
			strSort = Key.KEY_ALLMONEY;
		} else if (sortCode == 2) {
			strSort = Key.KEY_ZHANJI;
		} else {
			strSort = Config.NULLMARK;
		}

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_GET_HEMAILIST_FUCAI));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotId));
		list.add(mapItem(Key.KEY_EXPECT, expect));
		list.add(mapItem(Key.KEY_SORTFIELD, strSort));
		list.add(mapItem(Key.KEY_SORTORDER, strSorter));
		list.add(mapItem(Key.KEY_PAGESIZE, Integer.toString(pageSize)));
		list.add(mapItem(Key.KEY_PAGENO, Integer.toString(pageNo)));
		try {
			// 写入服务器返回信息
			super.getServerResponse(list, true);
			setMsgServer(super.getErrorMSG());
			if (super.getState() == 100) {
				isSucceed = true;
			} else {
				isSucceed = false;
			}
		} catch (Exception e) {
			isSucceed = false;
			setMsgServer(Language.STR_CONNECTIONFAIL);
		}
		return isSucceed;
	}

	// 返回合买信息
	public ArrayList<Fucai3DHemaiListItemInfo> getLotteryInfoList() {
		listHemaiListItemInfo.clear();
		int count = super.getListResult().size();
		for (int i = 0; i < count; i++) {
			Fucai3DHemaiListItemInfo hemaiListItemInfo = new Fucai3DHemaiListItemInfo();
			hemaiListItemInfo.setId(super.getListResult().get(i).get(Key.KEY_ID));
			hemaiListItemInfo.setProId(super.getListResult().get(i).get(Key.KEY_PROID));
			hemaiListItemInfo.setPlayType(super.getListResult().get(i).get(Key.KEY_PLAYTYPE));
			hemaiListItemInfo.setUserName(super.getListResult().get(i).get(Key.KEY_USERNAME));
			hemaiListItemInfo.setZhanji(super.getListResult().get(i).get(Key.KEY_ZHANJI));
			hemaiListItemInfo.setAllMoney(super.getListResult().get(i).get(Key.KEY_ALLMONEY));
			hemaiListItemInfo.setAllNum(super.getListResult().get(i).get(Key.KEY_ALLNUMBER));
			hemaiListItemInfo.setSellNum(super.getListResult().get(i).get(Key.KEY_HNUMBER));
			hemaiListItemInfo.setJindu(super.getListResult().get(i).get(Key.KEY_RENQI));
			hemaiListItemInfo.setEachMoney(super.getListResult().get(i).get(Key.KEY_ONEMONEY));
			hemaiListItemInfo.setSetOrder(super.getListResult().get(i).get(Key.KEY_SETORDER));
			listHemaiListItemInfo.add(hemaiListItemInfo);

		}
		return listHemaiListItemInfo;
	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
